package wjp.service.impl;

import java.util.List;

import org.springframework.transaction.annotation.Transactional;

import wjp.bean.Group;
import wjp.bean.Notice;
import wjp.bean.Result;
import wjp.dao.NoticeDao;
import wjp.service.NoticeService;
@Transactional
public class NoticeServiceImpl implements NoticeService {
	private NoticeDao noticeDao;
	
	public NoticeDao getNoticeDao() {
		return noticeDao;
	}

	public void setNoticeDao(NoticeDao noticeDao) {
		this.noticeDao = noticeDao;
	}

	@Override
	public List<Notice> list(String serachStr, Integer pageNum,
			Integer numPerPage) {
		List<Notice> list = noticeDao.list(serachStr, pageNum, numPerPage);
		for(Notice notice:list){
			if(notice.getContent()!=null&&notice.getContent().length()>25){
				String content = notice.getContent(); 
				content = content.substring(0, 24)+"...";
				notice.setContent(content);
			}
		}
		return list;
	}

	@Override
	public Result<Notice> findById(int id) {
		return noticeDao.findById(id);
	}

	@Override
	public void save(Notice notice) {
		noticeDao.save(notice);
	}

	@Override
	public void update(Notice notice) {
		noticeDao.update(notice);
	}

	@Override
	public void delete(Notice notice) {
		noticeDao.delete(notice);
	}

	@Override
	public void delete(int id) {
		noticeDao.delete(id);
	}

	@Override
	public Integer totalCount(String serachStr) {
		return noticeDao.totalCount(serachStr);
	}

	@Override
	public Result<Notice> apiList(Group group) {
		return noticeDao.apiList(group);
	}

}
